package org.cst.activity;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends Activity {
	
	EditText username;
	EditText password;
	Button login,register;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        initViews();
        setListener();
    }
    private void initViews()
    {
    	username=(EditText) findViewById(R.id.username);
    	password=(EditText) findViewById(R.id.password);
    	login=(Button) findViewById(R.id.login);
    	register=(Button) findViewById(R.id.register);
    	
    }
    private void setListener(){
    	login.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(null!=username||null!=password)
				{
					String name=username.getText().toString();
					String pass=password.getText().toString();
					Log.i("TAG", name+","+pass);

						Toast.makeText(LoginActivity.this, "bbb", Toast.LENGTH_LONG).show();
						Bundle b=new Bundle();
						b.putString("name", name);
						Intent i=new Intent();
						i.setClass(LoginActivity.this,ClientActivity.class);
						i.putExtras(b);
						startActivity(i);
					}else
					{
						Log.i("TAG", "登录失败");
						Toast.makeText(LoginActivity.this, "登录失败", Toast.LENGTH_LONG).show();
						
					}
			//	}
			}
		});
    	register.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent=new Intent(LoginActivity.this,RegisterActivity.class);
				startActivity(intent);
				
				
			}
		});
    }
}